//
//  HomeCollectionViewHeaderView.m
//  yimei
//
//  Created by Macx on 2018/1/28.
//  Copyright © 2018年 Macx. All rights reserved.
//

#import "HomeCollectionViewHeaderView.h"

@implementation HomeCollectionViewHeaderView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        self.backgroundColor = kWhiteColor;
        self.title = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, SW(2), 44)];
        self.title.font = kUHSystemFontWithSize(12);
        //左视图默认是不显示的 设置为始终显示
        self.title.leftViewMode= UITextFieldViewModeAlways;
        UIView *vv1 = [[UIView alloc] initWithFrame:CGRectMake(0, 7, 7, 30)];
        vv1.backgroundColor = UIMainColorRGB;
        self.title.leftView = vv1;
//        self.title.text = @" 爆款推荐";
        
        CGSize size = [LZCTools textSizeWithText:@"更多 >" font:kUHSystemFontWithSize(12)];
		self.more = [[UITextField alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-size.width-10, self.title.y, size.width, 44)];
        self.more.text = @"更多 >";
        self.more.font = kUHSystemFontWithSize(12);
//        self.more.rightViewMode= UITextFieldViewModeAlways;
//        UIImageView *imgV1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.height/2, size.height)];
//        imgV1.image = IMAGE(@"return");
//        UIButton *imgV1 = [UIButton buttonWithType:UIButtonTypeCustom];
//        imgV1.frame = CGRectMake(0, 0, 30, self.more.height);
//        [imgV1 setImage:IMAGE(@"arrow_right_grey") forState:UIControlStateNormal];
//        self.more.rightView = imgV1;
        
        self.moreV = [[UIView alloc] initWithFrame:CGRectMake(self.more.x, self.more.y, self.more.width, self.more.height)];
//        moreV.backgroundColor = kOrangeColor;
//        [self.moreV addTarget:self action:@selector(moreClick)];
        
        
        self.more.userInteractionEnabled = NO;
        self.title.userInteractionEnabled = NO;
        
        [self addSubview:self.title];
        [self addSubview:self.more];
        [self addSubview:self.moreV];
    }
    return self;
}

- (void)setIsFirst:(BOOL)isFirst
{
	_isFirst = isFirst;
	if (isFirst == YES) {
		self.backgroundColor = kWhiteColor;
		self.title.frame = CGRectMake(0, SW(5)*2, SW(2), 44);
		self.title.font = kUHSystemFontWithSize(12);
		
		CGSize size = [LZCTools textSizeWithText:@"更多 >" font:kUHSystemFontWithSize(12)];
		self.more.frame = CGRectMake(SCREEN_WIDTH-size.width-10, self.title.y, size.width, 44);
		
		self.moreV.frame = CGRectMake(self.more.x, self.more.y, self.more.width, self.more.height);
	}
	else {
		self.title.frame = CGRectMake(0, 0, SW(2), 44);
		self.title.font = kUHSystemFontWithSize(12);
		CGSize size = [LZCTools textSizeWithText:@"更多 >" font:kUHSystemFontWithSize(12)];
		self.more.frame = CGRectMake(SCREEN_WIDTH-size.width-10, self.title.y, size.width, 44);
		
		self.moreV.frame = CGRectMake(self.more.x, self.more.y, self.more.width, self.more.height);
	}
	
}

//- (void)moreClick {
//    NSLog(@"点击更多");
//}

@end
